home *** CD-ROM | disk | FTP | other *** search
- /*========================== my_timer.h ===================================*/
- /* "my_timer.h" A non-standard header file that defines the function-like */
- /* preprocessor macros START(desc) and STOP(); use to measure the */
- /* performance of coding alternatives; suitable for use with any ANSI C */
- /* compiler; software adapted from the book, ENCYCLOPEDIA C, by */
- /* R.Radcliffe (SYBEX/1991), Fig 5.1, Pg 234 */
- /* */
- /* NOTE: 1) #define MY_TIMER to activate START() and STOP */
- /* 2) re #define NTIMES as necessary - see my_timer.c */
- /* 3) CLK_TCK may be replaced with CLOCKS_PER_SEC */
- /* */
- /*=========================================================================*/
- #if !defined(MY_TIMER_DEFINED)
- # define NTIMES 30000
- # if defined(MY_TIMER)
- # include <stdio.h>
- # include <time.h>
- clock_t stop_tick, start_tick;
- # define START(desc) printf("\n\nfor : %s",#desc);\
- start_tick = clock() + (clock_t)1;\
- while (start_tick > clock());\
- start_tick = clock();
- # define TICKS (stop_tick - start_tick)
- # define STOP stop_tick = clock();\
- printf("\ntime: %7.2lf sec stop: %ld start: %ld\n",\
- (double)TICKS/(double)CLK_TCK, stop_tick, start_tick);
- # define MY_TIMER_DEFINED
- # else
- # define START(desc)
- # define STOP
- # endif
- #endif
- /*=========================== my_timer.h ==================================*/
-